package springboot_rabbitmq.consumer;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
@Slf4j
public class DeadLetterConsumer {

    /*
    * 消费死信队列的消息
    *    Message   相当于  deliver
    * */
    @RabbitListener(queues = "QD")
    public void receiveD(Message message){
        String msg = new String(message.getBody());
        log.info("当前时间{},收到死信队列的消息:{}",new Date(),msg);
    }


    public static final String DELAYED_QUEUE_NAME = "delayed.queue";
    @RabbitListener(queues = DELAYED_QUEUE_NAME)
    public void receiveDelay(Message message){
        String msg = new String(message.getBody());
        log.info("当前时间{},收到延迟队列的消息:{}",new Date(),msg);
    }
}
